<?php
/**
 * 获取钱包接口
 * 收入明细列表
 * 验证用户身份token
 * @author Edwin
 */

namespace V1\Controller;

use Common\Controller\ApiController;
use Think\Exception;
use V1\Model\PayModel;

class WalletController extends ApiController
{
    public function rest()
    {
        switch ($this->_method) {
            case 'get': // get请求处理代码
                $this->_get();
                break;
        }
    }

    /**
     * 获取收入明细
     */
    private function _get()
    {
        $pay = new PayModel();
        $filed = ['money,gold'];
        try {
            $result = $pay->get_recharge_list($this->userId, $filed);
            if ($result) {
                foreach ($result as $k => $v) {
                    $data[$k]['money'] = $v['money'];
                    $data[$k]['gold'] = $v['gold'];
                    $data[$k]['type'] = '充值';
                }
                $this->myApiPrint(C('STATUS')['200'], 200, $data);
            } else {
                $this->myApiPrint(C('STATUS')['230'], 201, []);
            }
        } catch (Exception $exception) {
            $this->myApiPrint(C('STATUS')['101'], 400, []);
        }
    }
}
